<?php
declare (strict_types = 1);

namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Db;

class GxTask extends Command
{
    protected function configure()
    {
        // 指令配置
        // 执行 php think gx:task
        $this->setName('gx:task')
            ->setDescription('the gxtask command');
    }

    protected function execute(Input $input, Output $output)
    {
        // 指令输出
        //$output->writeln('111gxtask');


        $data= Db::table('xj_news')->field('id,status')->where('status',0)->order("id")->limit(10)->select();
        if(!empty($data)){
            foreach($data as $v)
            {
                $info = [
                    'status' => 1,
                    'add_time' => date('Y-m-d H:i:s'),
                ];
                Db::table('xj_news')->where('id',$v['id'])->update($info);
                echo "执行成功";
            }

        }
    }
}
